<template>
  <div class="my">
    <div class="top">
      <div class="top1">
        <div class="left">
          <div class="left-name">{{ userInfo.nickname }}</div>
          <div class="left-text">{{ userInfo.intro }}</div>
        </div>
        <img
          @click="goinfo"
          v-if="userInfo.avatar"
          :src="baseUrl + userInfo.avatar"
          alt=""
          class="right"
        />
        <img
          v-else
          src="@/assets/曾小贤.jpg"
          alt=""
          class="right"
          @click="goinfo"
        />
      </div>
      <ul class="top2">
        <li class="top2-item">
          <div class="num">{{ userInfo.submitNum }}</div>
          <div class="txt">累计答题</div>
        </li>
        <li class="top2-item">
          <div class="num">{{ userInfo.collectQuestions.length }}</div>
          <div class="txt">收藏题目</div>
        </li>
        <li class="top2-item">
          <div class="num">{{ userInfo.errorQuestions.length }}</div>
          <div class="txt">我的错题</div>
        </li>
        <li class="top2-item">
          <div class="num">76%</div>
          <div class="txt">正确率</div>
        </li>
      </ul>
      <div class="top3">
        <myCell
          class="myCell"
          @click.native="$router.push('/home/eidtInfo?type=position')"
          title="我的岗位"
          :value="userInfo.position"
          icon="&#xe64d;"
        ></myCell>
      </div>
    </div>
    <div class="content">
      <div class="middle">
        <h3 class="middle-title">面经经验</h3>
        <ul class="middle-content">
          <li class="middle-item">
            <div class="item-top">
              昨日阅读<span>+{{ userInfo.shareData.read.yesterday }}</span>
            </div>
            <div class="item-middle">{{ userInfo.shareData.read.total }}</div>
            <div class="item-bottom">阅读总数</div>
          </li>
          <li class="middle-item">
            <div class="item-top">
              昨日阅读<span>+{{ userInfo.shareData.star.yesterday }}</span>
            </div>
            <div class="item-middle">{{ userInfo.shareData.star.total }}</div>
            <div class="item-bottom">获赞总数</div>
          </li>
          <li class="middle-item">
            <div class="item-top">
              昨日阅读<span>+{{ userInfo.shareData.comment.yesterday }}</span>
            </div>
            <div class="item-middle">
              {{ userInfo.shareData.comment.total }}
            </div>
            <div class="item-bottom">评论总数</div>
          </li>
        </ul>
      </div>
    </div>
    <div class="bottom">
      <myCell title="我的面经分享" value="21" icon="&#xe655;"></myCell>
      <myCell title="我的消息" value="98" icon="&#xe656;"></myCell>
      <myCell title="收藏的题库" value="32" icon="&#xe654;"></myCell>
      <myCell title="收藏的企业" value="32" icon="&#xe648;"></myCell>
      <myCell title="我的错题" value="123" icon="&#xe64f;"></myCell>
      <myCell title="收藏的面试经验" value="166" icon="&#xe649;"></myCell>
    </div>
  </div>
</template>

<script>
// 导入相同组件提高利用率
import myCell from './myCell'
// 导入组件
import { mapState } from 'vuex'
// import { getLocal } from '@/utils/local.js'
export default {
  components: {
    myCell
  },
  mounted () {
    document.querySelector('body').style.background = '#f7f4f5'
  },
  beforeDestroy () {
    document.querySelector('body').style.backgroundColor = '#fff'
  },
  data () {
    return {
      baseUrl: process.env.VUE_APP_URL
    }
  },
  computed: {
    ...mapState(['userInfo', 'isLogin'])
  },
  methods: {
    goinfo () {
      this.$router.push('/home/myInfo')
    }
  }
}
</script>

<style lang="less" scoped>
.my {
  .top {
    background-color: #b8002c;
    padding: 31px @p15 0;
    position: relative;
    .top1 {
      display: flex;
      justify-content: space-between;
      .left {
        flex: 1;
        .left-name {
          font-size: 21px;
          font-family: PingFangSC, PingFangSC-Semibold;
          font-weight: 600;
          text-align: left;
          color: #ffffff;
          line-height: 30px;
          letter-spacing: 0px;
        }
        .left-text {
          opacity: 0.7;
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: left;
          color: #ffffff;
          line-height: 16px;
          letter-spacing: 0px;
        }
      }
      .right {
        width: 50px;
        height: 50px;
        border: 6px solid rgba(255, 255, 255, 0.38);
        border-radius: 50%;
      }
    }
    .top2 {
      margin-top: 28px;
      padding-bottom: 55px;
      display: flex;
      justify-content: space-between;
      .top2-item {
        text-align: center;
        .num {
          font-size: 21px;
          font-family: DINAlternate, DINAlternate-Bold;
          font-weight: 700;
          text-align: center;
          color: #ffffff;
          line-height: 24px;
          letter-spacing: 0px;
        }
        .txt {
          opacity: 0.7;
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: center;
          color: #ffffff;
          line-height: 16px;
          letter-spacing: 0px;
        }
      }
    }
    .top3 {
      position: absolute;
      left: 0;
      bottom: -16px;
      width: 100%;
      padding: 0 @p15;
      // padding-bottom: 6px;
      .myCell {
        border-radius: 8px;
      }
    }
  }
  .content {
    padding: 25px @p15 10px;
    background-color: #f7f4f5;
    .middle {
      background-color: #ffffff;
      padding: 19px 15px;
      border-radius: 10px;
      .middle-title {
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
        text-align: left;
        color: #181a39;
        line-height: 20px;
        letter-spacing: 0px;
        margin-bottom: 17px;
      }
      .middle-content {
        display: flex;
        text-align: center;
        justify-content: space-between;
        .item-top {
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: center;
          color: #b4b4bd;
          line-height: 28px;
          letter-spacing: 0px;
          margin-bottom: 10px;
          span {
            color: #00b8d4;
          }
        }
        .item-middle {
          font-size: 21px;
          font-family: DINAlternate, DINAlternate-Bold;
          font-weight: 700;
          text-align: center;
          color: #181a39;
          line-height: 14px;
          letter-spacing: 0px;
          margin: 10px 0 6px;
        }
        .item-bottom {
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: center;
          color: #545671;
          line-height: 16px;
          letter-spacing: 0px;
        }
      }
    }
  }
  .bottom {
    background-color: #f7f4f5;
    padding: 0 @p15;
  }
}
</style>
